﻿$(document).ready(function() {

    $.validator.addMethod("validcb1", function(value) {
        if ($("input:checked").length > 0) return true;
        else return false;
    }, "");

    $("fieldset input").click(function() { $(".validation-summary-errors").remove() });

    $("#NetModelTemplateForm").validate({
        rules: {
            NodesCount: {
                required: true,
                range: [1, 20]
            },
        },
        messages: {
            NodesCount: {
                required: "поле не заполнено или заполнено не верно",
                range: "в поле должно быть число от 1 до 20",
            },
        },
        errorPlacement: function(v, element) {
            if (element.attr("name") == "NodesCount") v.insertAfter($("input[name=NodesCount]"));
        }
    });
});

jQuery(document).ready(function() {
    $('.dropdown-toggle').dropdown()
});

!function ($) {
    "use strict"; var toggle = '[data-toggle="dropdown"]', Dropdown = function (element) {
        var $el = $(element).on('click.dropdown.data-api', this.toggle)
        $('html').on('click.dropdown.data-api', function () { $el.parent().removeClass('open') })
    }
    Dropdown.prototype = {
        constructor: Dropdown, toggle: function (e) {
            var $this = $(this), $parent, selector, isActive
            if ($this.is('.disabled, :disabled')) return
            selector = $this.attr('data-target')
            if (!selector) {
                selector = $this.attr('href')
                selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '')
            }
            $parent = $(selector)
            $parent.length || ($parent = $this.parent())
            isActive = $parent.hasClass('open')
            clearMenus()
            if (!isActive) $parent.toggleClass('open')
            return false
        }
    }
    function clearMenus() { $(toggle).parent().removeClass('open') }
    $.fn.dropdown = function (option) {
        return this.each(function () {
            var $this = $(this), data = $this.data('dropdown')
            if (!data) $this.data('dropdown', (data = new Dropdown(this)))
            if (typeof option == 'string') data[option].call($this)
        })
    }
    $.fn.dropdown.Constructor = Dropdown
    $(function () {
        $('html').on('click.dropdown.data-api', clearMenus)
        $('body').on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() }).on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
    })
}(window.jQuery);


    function for_sel(a) {

        var label = a.value;

        if (label == "Типовой шаблон") {
            document.getElementById("Label1").style.display = 'block';
            document.getElementById("Label2").style.display = 'none';
            document.getElementById("Label3").style.display = 'block';


        } else if (label == "Ручной ввод") {
            document.getElementById("Label1").style.display = 'none';
            document.getElementById("Label2").style.display = 'block';
            document.getElementById("Label3").style.display = 'block';


        } else if (label == "Тестовая сеть") {
            document.getElementById("Label1").style.display = 'none';
            document.getElementById("Label2").style.display = 'none';
            document.getElementById("Label3").style.display = 'block';


        } else {
            document.getElementById("Label1").style.display = 'none';
            document.getElementById("Label2").style.display = 'none';
            document.getElementById("Label3").style.display = 'none';

        }

    }

    function printHtml2(a) {
        var label = a.value;
        $.ajax({
            
        dataType: "html",
        url: "/Home/pNet",
        data: null,
        type: "POST",
        traditional: true,
        success: function (data)
        {
            $("#pNet").html(data);
            //$.get("/Home/pNet", { x: label }, function () {
            //  document.location.href = '/Home/pNet' + x;
            //});
            //document.write('Значение PHP-переменной: ' + label);
           
            result.innerHTML = label;

        }
    });

    }

    function print() {
        
        document.getElementById("Label0").style.display = 'block';

    }